<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>判断一个图像的类型</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.exif-imagetype" class="refentry">
  <div class="refnamediv">
   <h1 class="refname">exif_imagetype</h1>
   <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">exif_imagetype</span> &mdash; <span class="dc-title">判断一个图像的类型</span></p>

  </div>
  <div class="refsect1 description" id="refsect1-function.exif-imagetype-description">
   <h3 class="title">说明</h3>
   <div class="methodsynopsis dc-description">
    <span class="methodname"><strong>exif_imagetype</strong></span>
     ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
    ) : <span class="type">int</span></div>

   <p class="para rdfs-comment">
    <span class="function"><strong>exif_imagetype()</strong></span> 读取一个图像的第一个字节并检查其签名。
   </p>
   <p class="para">
    本函数可用来避免调用其它 <a href="ref.exif.html" class="link">exif</a>
    函数用到了不支持的文件类型上或和
    <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER['HTTP_ACCEPT']</a></var></var>
    结合使用来检查浏览器是否可以显示某个指定的图像。
   </p>
  </div>

  <div class="refsect1 parameters" id="refsect1-function.exif-imagetype-parameters">
   <h3 class="title">参数</h3>
   <p class="para">
    <dl>

     
      <dt>
<code class="parameter">filename</code></dt>

      <dd>

       <span class="simpara">
        被检查的图像文件名。
       </span>
      </dd>

     
    </dl>

   </p>
  </div>

  <div class="refsect1 returnvalues" id="refsect1-function.exif-imagetype-returnvalues">
   <h3 class="title">返回值</h3>
   <p class="para">
    如果发现了恰当的签名则返回一个对应的常量，否则返回
    <strong><code>FALSE</code></strong>。返回值和 <span class="function"><a href="getimagesize.html" class="function">getimagesize()</a></span>
    返回的数组中的索引 2 的值是一样的，但本函数快得多。
   </p>
  </div>

  <div class="refsect1 changelog" id="refsect1-function.exif-imagetype-changelog">
   <h3 class="title">更新日志</h3>
   <p class="para">
    <table class="doctable informaltable">
     
      <thead>
       <tr>
        <th>版本</th>
        <th>说明</th>
       </tr>

      </thead>

      <tbody class="tbody">
       <tr>
        <td>4.3.2</td>
        <td>
         支持
         <acronym title="Japan Picture">JPC</acronym>，<acronym title="JPEG-2000">JP2</acronym>，<acronym>JPX</acronym>，<acronym title="Joint Bilevel Image Experts Group">JB2</acronym>，<acronym title="X Bitmap">XBM</acronym>
         以及 <acronym title="Wireless Bitmap">WBMP</acronym>
        </td>
       </tr>

       <tr>
        <td>4.3.0</td>
        <td>支持 <acronym>SWC</acronym></td>
       </tr>

      </tbody>
     
    </table>

   </p>
  </div>

  <div class="refsect1 constants" id="refsect1-function.exif-imagetype-constants">
   <h3 class="title">预定义常量</h3>
   <p class="para">
    定义有以下常量，并代表了 <span class="function"><strong>exif_imagetype()</strong></span> 可能的返回值：
    <table class="doctable table">
    <caption><strong>图像类型常量</strong></caption>
     
      <thead>
       <tr>
        <th>值</th>
        <th>常量</th>
       </tr>

      </thead>

      <tbody class="tbody">
       <tr>
        <td>1</td>
        <td><strong><code>IMAGETYPE_GIF</code></strong></td>
       </tr>

       <tr>
        <td>2</td>
        <td><strong><code>IMAGETYPE_JPEG</code></strong></td>
       </tr>

       <tr>
        <td>3</td>
        <td><strong><code>IMAGETYPE_PNG</code></strong></td>
       </tr>

       <tr>
        <td>4</td>
        <td><strong><code>IMAGETYPE_SWF</code></strong></td>
       </tr>

       <tr>
        <td>5</td>
        <td><strong><code>IMAGETYPE_PSD</code></strong></td>
       </tr>

       <tr>
        <td>6</td>
        <td><strong><code>IMAGETYPE_BMP</code></strong></td>
       </tr>

       <tr>
        <td>7</td>
        <td><strong><code>IMAGETYPE_TIFF_II</code></strong>（Intel 字节顺序）</td>
       </tr>

       <tr>
        <td>8</td>
        <td>
         <strong><code>IMAGETYPE_TIFF_MM</code></strong>（Motorola 字节顺序）
        </td>
       </tr>

       <tr>
        <td>9</td>
        <td><strong><code>IMAGETYPE_JPC</code></strong></td>
       </tr>

       <tr>
        <td>10</td>
        <td><strong><code>IMAGETYPE_JP2</code></strong></td>
       </tr>

       <tr>
        <td>11</td>
        <td><strong><code>IMAGETYPE_JPX</code></strong></td>
       </tr>

       <tr>
        <td>12</td>
        <td><strong><code>IMAGETYPE_JB2</code></strong></td>
       </tr>

       <tr>
        <td>13</td>
        <td><strong><code>IMAGETYPE_SWC</code></strong></td>
       </tr>

       <tr>
        <td>14</td>
        <td><strong><code>IMAGETYPE_IFF</code></strong></td>
       </tr>

       <tr>
        <td>15</td>
        <td><strong><code>IMAGETYPE_WBMP</code></strong></td>
       </tr>

       <tr>
        <td>16</td>
        <td><strong><code>IMAGETYPE_XBM</code></strong></td>
       </tr>

      </tbody>
     
    </table>

   </p>
  </div>

  <div class="refsect1 examples" id="refsect1-function.exif-imagetype-examples">
   <h3 class="title">范例</h3>
   <p class="para">
    <div class="example" id="example-3633">
     <p><strong>Example #1 <span class="function"><strong>exif_imagetype()</strong></span> 例子</strong></p>
      <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">exif_imagetype</span><span style="color: #007700">(</span><span style="color: #DD0000">"image.gif"</span><span style="color: #007700">)&nbsp;!=&nbsp;</span><span style="color: #0000BB">IMAGETYPE_GIF</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;picture&nbsp;is&nbsp;not&nbsp;a&nbsp;gif"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
      </div>

     </div>
   </p>
  </div>

  <div class="refsect1 seealso" id="refsect1-function.exif-imagetype-seealso">
   <h3 class="title">参见</h3>
   <p class="para">
    <ul class="simplelist">
     <li class="member"><span class="function"><a href="getimagesize.html" class="function" rel="rdfs-seeAlso">getimagesize()</a> - 取得图像大小</span></li>
    </ul>
   </p>
  </div>

 </div></div></div></body></html>